# $Id: PKGBUILD 81918 2013-01-03 13:12:28Z fyan $
# Maintainer: Felix Yan <felixonmars@gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=ibus-sunpinyin
pkgver=2.0.3.20130103
_commit=baf4da89ac04c3eb6ea3b8fb1a10f13bf23f3d87
pkgrel=1
pkgdesc="IBus Wrapper for sunpinyin."
arch=('i686' 'x86_64')
url="http://sunpinyin.googlecode.com"
license=('LGPL')
depends=('sunpinyin>2.0.3' 'sunpinyin-data' 'ibus')
makedepends=('git' 'scons')

__gitroot=git://github.com/sunpinyin/sunpinyin.git
__gitname=sunpinyin

build() {
  cd "$srcdir"
  msg "Connecting to GIT server...."

  if [ -d $__gitname ] ; then
    cd $__gitname && git pull origin
    msg "The local files are updated."
  else
    git clone $__gitroot
  fi

  msg "GIT checkout done or server timeout"
  msg "Starting make..."

  rm -rf "$srcdir/$__gitname-build"
  git clone "$srcdir/$__gitname" "$srcdir/$__gitname-build"
  cd "$srcdir/$__gitname-build"
  git checkout "$_commit"

  cd "$srcdir/$__gitname-build/wrapper/ibus"
  sed -i -e "s|python|python2|" setup/ibus-setup-sunpinyin.in
  
  scons \
    --prefix=/usr
}

package() {
  cd "$srcdir/$__gitname-build/wrapper/ibus"

  scons \
    --prefix=/usr \
    --install-sandbox="$pkgdir" \
    install
}
